<?php
declare (strict_types = 1);

namespace app\common\validate;

use think\Validate;

class Login extends Validate
{
	protected $rule = [
        'account'           => 'require|max:64',
        'captcha'           => 'require|print|checkCaptcha',
        'password'          => 'require|min:6',
        'remember'          => 'print',
    ];

    protected $message = [
        'account.require'  => '账号必须',
        'account.max'      => '账号最多不能超过64个字符',

        'captcha.require' => '验证码必须',
        'captcha.print'   => '验证码无效',
        'captcha.checkCaptcha' => '验证码错误',

        'password.require'      => '密码必须',
        'password.min'          => '密码最小为6个字符',

        'remember.print'          => '记住我类型错误',
    ];


    /**
     * 验证邮箱验证码是否有效
     * @param string $value post提交的验证码
     * @return bool
     */
    public function checkCaptcha($value){

        if( !captcha_check($value ))
        {
            return false;
        }
        return true;
    }


}
